package com.hskn.hss.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class GroupingByUtils {
    public static <T, K> Map<K, List<T>>
    getGroupingForMapList(List<T> list,Function<? super T, ? extends K> classifier) {
        return list.stream().collect(Collectors.groupingBy(classifier, Collectors.toList()));
    }
    public static <T, K, A, D>
     Map<K, D> getGroupingForMapEntity(List<T> list,Function<? super T, ? extends K> classifier,
                                          Collector<? super T, A, D> downstream) {

        return list.stream().collect(Collectors.groupingBy(classifier, HashMap::new, downstream));
    }
}
